using UnityEngine;
public class GameManager : MonoBehaviour
{
    public static GameManager ins;
    public PlayerCtrl playerCtrl;
    public MobileJoy mobileJoy;
    public RoleInfo player; // 当前玩家
    void Awake()
    {
        ins = this;
        playerCtrl = GetComponent<PlayerCtrl>();
        if (Application.isMobilePlatform) playerCtrl.enabled = false; // 手机端禁用键盘控制
    }
    void Start()
    {
        if (player) SetPlayer(player); // 默认加载角色
    }
    /// <summary>设置当前控制角色，并更新相机目标</summary>
    public void SetPlayer(RoleInfo role)
    {
        if (playerCtrl) playerCtrl.role = role; //控制角色
        mobileJoy.role = role; // 摇杆控制角色
        CameraController.ins.target = role.transform; // 更新相机目标
    }
}